package com.meizu.hjcool7.androidchecklist;

import com.meizu.hjcool7.androidchecklist.util.ViewHolder;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MainTempListFragment extends BaseFragment
{	
	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{  
		ListView rooView = (ListView) inflater.inflate(R.layout.fragment_main_temp_list, container, false);
		rooView.setAdapter(new ListAdapter(getActivity()));
        return rooView;
    }
	
	public class ListAdapter extends BaseAdapter
	{
		private LayoutInflater mInflater;
		
		public ListAdapter(Context context)
		{
			this.mInflater = LayoutInflater.from(context);
		}
		@Override
		public int getCount()
		{
			return 10;
		}

		@Override
		public Object getItem(int arg0)
		{
			return null;
		}

		@Override
		public long getItemId(int arg0)
		{
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent)
		{
			ViewHolder holder = null;
			if (convertView == null)
			{	
				holder = new ViewHolder();
				convertView = mInflater.inflate(R.layout.cell_main_temp_list, parent, false);
				holder.addView(R.id.titleTextView, convertView.findViewById(R.id.titleTextView));
				convertView.setTag(holder);
			}
			else
			{
				holder = (ViewHolder)convertView.getTag();
			}
			
			TextView titleTextView = (TextView) holder.getView(R.id.titleTextView);
			titleTextView.setText(position + "");			
			
			return convertView;
		}
		
	}
}
